<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./template-web.js"></script>
</head>
<body>
    <div ></div>

    <!-- 定义一个模板 -->
    <script id="demo" type="text/html">
        {{ each arrs value index }}
            <p>{{ value.username }}</p>
        {{ /each }}

    </script>
    <script>
        var arrs=[
            {
                id:1001,
                username:"老王"
            },
            {
                id:1002,
                username:"老许"
            },
            {
                id:1003,
                username:"老陈"
            }
        ];

        // template(id,data)
        // id:模板id
        // data:数据格式一定要是对象格式
        var objs={"arrs":arrs};
       
        var str=template("demo",objs);
        var div=document.querySelector("div");
        div.innerHTML=str;

            
    </script>
</body>
</html>